#include "gmTvQIODevice.h"


mTVDevice::mTVDevice()
{
file=new QFile("/home/shh/lp-nd.mp3");
}

mTVDevice::mTVDevice(QUrl tempUrl)
{
qDebug()<<__func__;
file=new QFile("/home/test.wav");

qDebug()<<"url being used is "<<tempUrl;
url=tempUrl;
}

mTVDevice:: ~mTVDevice()
{
delete stream;
delete file;
}

bool mTVDevice::open ( QIODevice::OpenMode mode )
{
file->open(mode);
stream=new QDataStream(file);
qDebug()<<__func__<<mode<<"file->exists()=="<<file->exists();
return TRUE;
}

qint64 mTVDevice::pos() const
{
qDebug()<<__func__<<position;
return position; 
}


bool mTVDevice::seek ( qint64 pos ) 
{
position=pos;
//QIODevice::seek(pos);
qDebug()<<__func__<<pos;
file->seek(pos);
return TRUE;
}

qint64 mTVDevice::size () const 
{
qDebug()<<__func__<<file->size();
return (file->size());
}


void mTVDevice::close()
{
qDebug()<<__func__;
file->close();
}
bool mTVDevice::isSequential ()
{
qDebug()<<__func__;
return FALSE;//it's random
}

qint64 mTVDevice::readData ( char * data, qint64 maxSize )
{
qDebug()<<__func__;
qint64 returnValue=stream->readRawData(data,maxSize);
qDebug()<<returnValue;
return returnValue;
//return qint64(0);
}

qint64 mTVDevice::writeData ( const char * data, qint64 maxSize )
{
qDebug()<<__func__;
return stream->writeRawData(data,maxSize);

//return qint64(0);
}

